import sys
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *


class SliderDemo(QWidget):
    def __init__(self, parents=None):
        super(SliderDemo, self).__init__(parents)
        self.setWindowTitle('Slider')
        self.resize(300, 100)

        layout = QVBoxLayout()
        self.l1 = QLabel('Hello QT5')
        self.l1.setAlignment(Qt.AlignCenter)
        layout.addWidget(self.l1)
        self.sl = QSlider(Qt.Horizontal)

        self.sl.setMinimum(10)
        self.sl.setMaximum(50)
        self.sl.setSingleStep(3)
        self.sl.setValue(20)

        self.sl.setTickPosition(QSlider.TicksBelow)
        self.sl.setTickInterval(5)
        layout.addWidget(self.sl)

        self.sl.valueChanged.connect(self.valuechange)
        self.setLayout(layout)

    def valuechange(self):
        print('current value=%s' % self.sl.value())
        size = self.sl.value()
        self.l1.setFont(QFont('Arial', size))


if __name__ == '__main__':
    app = QApplication(sys.argv)
    de = SliderDemo()
    de.show()
    sys.exit(app.exec_())
